package online.lmds.sdmanage.main.authentication.controller;

import online.lmds.sdmanage.common.entity.Result;
import online.lmds.sdmanage.main.authentication.entity.User;
import online.lmds.sdmanage.main.authentication.service.UserService;
import online.lmds.sdmanage.main.base.BaseContoller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Brighten Ma on 2017/4/10.
 * 用户、权限
 */
@Controller
@RequestMapping("/user")
public class UserController extends BaseContoller {

    @Resource(name = "UserService")
    private UserService userService;


    @RequestMapping(value = "/login")
    @ResponseBody
    public Object login(HttpServletResponse response, User user) {
        Result result = userService.login(user);
        return result;
    }

    @RequestMapping(value = "/register")
    @ResponseBody
    public Object register(HttpServletResponse response, User user){
        return userService.regAddUser(user);
    }


    @RequestMapping(value = "/updateUserInfo")
    @ResponseBody
    public Object updateUserInfo(HttpServletResponse response, User user){
        setUserInfo(user);
        return userService.updateById(user);

    }

    @RequestMapping(value ="/getByToken" )
    @ResponseBody
    public Object getByToken(HttpServletResponse response, User user){
        return userService.getByToken(user);
    }
}
